

using System.Web.UI.WebControls;
using System.Web.UI;
using System.ComponentModel;
using System.ComponentModel.Design;
using AjaxControlToolkit;


#region Assembly Resource Attribute
[assembly: System.Web.UI.WebResource("GridControl.GridControlBehavior.js", "text/javascript")]
#endregion


namespace GridControl
{
    /// <summary>
    /// Extender used to pass the propertie values to the control
    /// </summary>
    [Designer(typeof(GridControlDesigner))]
    [ClientScriptResource("GridControl.GridControlBehavior", "GridControl.GridControlBehavior.js")]
    [RequiredScript(typeof(YUI),1)]
    [RequiredScript(typeof(ext_yui_adapter), 2)]
    [RequiredScript(typeof(YUI_ext), 3)]
    [RequiredScript(typeof(GridExtenstions),4)]
    [ToolboxItem(false)]
    [TargetControlType(typeof(Control))]
    public class GridControlExtender : ExtenderControlBase
    {
        /// <summary>
        /// Gets or sets the grid control id.
        /// </summary>
        /// <value>The grid control id.</value>
        [ExtenderControlProperty]
        public string GridControlId
        {
            get
            {
                return GetPropertyValue<string>("GridControlId",string.Empty);
            }
            set
            {
                SetPropertyValue<string>("GridControlId", value);
            }
        }
        /// <summary>
        /// Gets or sets the processing page.
        /// </summary>
        /// <value>The processing page.</value>
        [ExtenderControlProperty]
        public string ProcessingPage
        {
            get
            {
                return GetPropertyValue<string>("ProcessingPage",string.Empty);
            }
            set
            {
                 SetPropertyValue<string>("ProcessingPage", value);
            }
        }
        /// <summary>
        /// Custom object passed with json
        /// </summary>
        [ExtenderControlProperty]
        public string Columns
        {
            get
            {
                return GetPropertyValue<string>("Columns",string.Empty);
            }
            set
            {
                 SetPropertyValue<string>("Columns", value);
            }
        }
        /// <summary>
        /// Tag that will be repeated in the xml returned
        /// by the server
        /// </summary>
        [ExtenderControlProperty] 
        public string TagName
        {
            get
            {
                return GetPropertyValue<string>("TagName",string.Empty);
            }
            set
            {
                 SetPropertyValue<string>("TagName", value);
            }
        }
        /// <summary>
        /// Tag that will contain the total number of rows
        /// </summary>
        [ExtenderControlProperty] 
        public string totalTag
        {
            get
            {
                return GetPropertyValue<string>("totalTag",string.Empty);
            }
            set
            {
                 SetPropertyValue<string>("totalTag", value);
            }
        }
        /// <summary>
        /// Name of the tag that will contain 
        /// the identifier of the record
        /// </summary>
        [ExtenderControlProperty]
        public string IdRecord
        {
            get
            {
                return GetPropertyValue<string>("IdRecord",string.Empty);
            }
            set
            {
                 SetPropertyValue<string>("IdRecord", value);
            }
        }
        /// <summary>
        /// Tags on the xml that will be displayed on the grid
        /// </summary>
        [ExtenderControlProperty]
        public string Fields
        {
            get
            {
                return GetPropertyValue<string>("Fields",string.Empty);
            }
            set
            {
                 SetPropertyValue<string>("Fields", value);
            }
        }
        /// <summary>
        /// Enables drag and drop row sorting
        /// </summary>
        [ExtenderControlProperty]
        public bool EnableRowSorting
        {
            get
            {
                return GetPropertyValue<bool>("EnableRowSorting",false);
            }
            set
            {
                SetPropertyValue<bool>("EnableRowSorting", value);
            }
        }
        /// <summary>
        /// Enables paging
        /// </summary>
        [ExtenderControlProperty]
        public bool EnablePaging
        {
            get
            {
                return GetPropertyValue<bool>("EnablePaging",false);
            }
            set
            {
                SetPropertyValue<bool>("EnablePaging", value);
            }
        }
        /// <summary>
        /// Page size
        /// </summary>
        [ExtenderControlProperty]
        public int PageSize
        {
            get
            {
                return GetPropertyValue<int>("PageSize",0);
            }
            set
            {
                SetPropertyValue<int>("PageSize", value);
            }
        }
        /// <summary>
        /// Enables SelectMultiple records
        /// </summary>
        [ExtenderControlProperty]
        public bool SelectMultiple
        {
            get
            {
                return GetPropertyValue<bool>("SelectMultiple",false);
            }
            set
            {
                SetPropertyValue<bool>("SelectMultiple", value);
            }
        }
        /// <summary>
        /// Gets or sets the web service method.
        /// </summary>
        /// <value>The web service method.</value>
        [ExtenderControlProperty]
        public string WebServiceMethod
        {
            get
            {
                return GetPropertyValue<string>("WebServiceMethod", null);
            }
            set
            {
                SetPropertyValue<string>("WebServiceMethod", value);
            }
        }
        /// <summary>
        /// Gets or sets the web service path.
        /// </summary>
        /// <value>The web service path.</value>
        [ExtenderControlProperty]
        public string WebServicePath
        {
            get
            {
                return GetPropertyValue<string>("WebServicePath", null);
            }
            set
            {
                SetPropertyValue<string>("WebServicePath", value);
            }
        }
        /// <summary>
        /// Gets or sets the paging style.
        /// </summary>
        /// <value>The paging style.</value>
        [ExtenderControlProperty]
        public PagingStyle PagingStyle
        {
            get
            {
                return GetPropertyValue<PagingStyle>("PagingStyle", PagingStyle.NumberPaging);
            }
            set
            {
                SetPropertyValue<PagingStyle>("PagingStyle", value);
            }
        }

        ///// <summary>
        ///// Enables add/delete row buttons to the footer toolbar.
        ///// </summary>
        //[ExtenderControlProperty]
        //public bool EnableAddDeleteRows
        //{
        //    get
        //    {
        //        return GetPropertyValue<bool>("EnableAddDeleteRows", false);
        //    }
        //    set
        //    {
        //        SetPropertyValue<bool>("EnableAddDeleteRows", value);
        //    }
        //}

        ///// <summary>
        ///// Enables Inline Editing for grid cells.
        ///// </summary>
        //[ExtenderControlProperty]
        //public bool EnableInlineEditing
        //{
        //    get
        //    {
        //        return GetPropertyValue<bool>("EnableInlineEditing", false);
        //    }
        //    set
        //    {
        //        SetPropertyValue<bool>("EnableInlineEditing", value);
        //    }
        //}
    }
}


